import java.util.Vector;

public class SimbolTable {
	private Vector Simbolos;

	public SimbolTable() {
		Simbolos = new Vector<String>();
	}	

	private int getTokenPos(String id, String token) {
		for (int i = 0; i < Simbolos.size(); i++) {
			SimbolNode SN = (SimbolNode) Simbolos.get(i);
			if ((id.equals(SN.getId())) && (token.equals(SN.getToken()))) {
				return i;
			}
		}
		return -1;
	}

	public void insertToken(String id, String token) {
		if (getTokenPos(id, token) == -1) {
			SimbolNode SN = new SimbolNode(id, token);
			Simbolos.add(SN);
		}
	}

	public Vector<String> getSimbolos() {
		return Simbolos;
	}

	public String toString() {
		String res = "";
		for (int i = 0; i < Simbolos.size(); i++) {
			res += "<" + i + ">: " + Simbolos.get(i).toString();
			res += System.getProperty("line.separator");
		}
		return res;
	}
}
